% struct to table 
function [response,colName]=sqlite3(db_or_opts,SQL_statement,input_struct)

 
if nargin<2 || nargin>3
    return;
 
end
if nargout>2
     return;
end
if nargout==0   
    return;
end

if nargout >0
    response=table;
end
if nargout >1
     colName=cell(1);  
end

 args = {db_or_opts,SQL_statement};if nargin>=3,args{end+1} = reshape(input_struct,1,[]);end

if nargin ==3
     
    if ~isa(args{3},'struct')
        return;
    end
end
 
    funname='sql64';
    fun_handle = str2func(funname);
    
try  
    c = cell(1,2);
    [c{:}] = feval(fun_handle,args{:});
   
catch ME
 disp(ME)
 
end

    response_struct = c{1};
    SQLiteFieldnames = c{2};
% A normal clear would wipe the persistent.

    
if ~isa(response_struct,'struct')
    return;
end
onum=numel(SQLiteFieldnames);
outputname=cell(1,onum);

j=0;
for n=1:onum
    if(isempty(SQLiteFieldnames{n}))
        continue;
    end
     j=j+1;
    outputname{1,j}= native2unicode(SQLiteFieldnames{n},'UTF-8');
   
end
outputname =outputname(1:j);
rTable = struct2table(response_struct);
if(size(rTable,2) ==size(outputname,2))
rTable.Properties.VariableNames = outputname;
end

if nargout >0
   response = rTable;
end

if nargout >1 
    colName = outputname;
end

end
 





